
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

ENT.amount = 50

/*---------------------------------------------------------
   Name: Initialize
---------------------------------------------------------*/
function ENT:Initialize()

	self.Entity:SetModel( "models/props_junk/garbage_plasticbottle003a.mdl" )
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
	self.Entity:SetSolid( SOLID_VPHYSICS )
	
	local phys = self.Entity:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:Wake()
	end
	
	self.Entity:SetColor(255, 255, 255, 150)
	self.Entity:SetMaterial("models/shiny")
	
end

function ENT:Use( activator, caller )

	if (self.Entity:IsFilled() && self.Entity:WaterLevel() == 0) then
		
		if (activator:IsPlayer()) then
		
			if (activator:AddNWInt("thirst", self.amount, DRINKING_ALLOW, DRINKING_DENY)) then
			
				self.Entity:SetColor(255, 255, 255, 150)
				
			end
			
		end
	
	end

end

/*---------------------------------------------------------
   Name: OnTakeDamage
---------------------------------------------------------*/
function ENT:OnTakeDamage( dmginfo )

	// React physically when shot/getting blown
	self.Entity:TakePhysicsDamage( dmginfo )
	
end

function ENT:IsFilled()

	local r, g, b = self.Entity:GetColor()
	
	if (r == 255 && g == 255 && b == 255) then
	
		return false
		
	else
	
		return true
		
	end

end

function ENT:Think()

	if (!self.Entity:IsFilled()) then

		if (self.Entity:WaterLevel() != 0) then

			self.Entity:SetColor(0, 0, 150, 150)
		
		end
		
	end
	
end